{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}表维护
{% endblock %}


{% block content %}
<input type="submit" onclick="location.href='/web_dim_db?product_id={{ product_id }}'" value="返回数据库"></input><br><br>

<form id="table" name="table" action="/web_db_table_relate?db_id={{ db_id }}" method="post">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
    <div class="form-row">
            <div class="form-group col-md-2">
                <label>表名</label>
                <input type="text" id="table_name" name="table_name" class="form-control" placeholder="表名"></input>
            </div>
            <div class="form-group col-md-3">
                <label>表描述</label>
                <input type="text" id="table_describe" name="table_describe" class="form-control" placeholder="表描述"></input>
            </div>
        {% if (db_driver_name == 'HIVE') %}

            <div class="form-group col-md-1">
                <label>是否外部表</label>
                <select id="table_type" name="table_type" class="form-control">
                    <option id="管理表" name="管理表" value="1">管理表</option>
                    <option id="外部表" name="外部表" value="2">外部表</option>
                </select>
            </div>

            <div class="form-group col-md-1">
                <label>存储格式</label>
                <select id="formatdata" name="formatdata" class="form-control">
                    <option selected id="TEXTFILE" name="TEXTFILE" value="TEXTFILE">TEXTFILE</option>
                    <option id="ORC" name="ORC" value="ORC">ORC</option>
                    <option id="RCFILE" name="RCFILE" value="RCFILE">RCFILE</option>
                    <option id="SEQUENCEFILE" name="SEQUENCEFILE" value="SEQUENCEFILE">SEQUENCEFILE</option>
                    <option id="PARQUET" name="PARQUET" value="PARQUET">PARQUET</option>
                    <option id="AVRO" name="AVRO" value="AVRO">AVRO</option>
                    <option id="JSONFILE" name="JSONFILE" value="JSONFILE">JSONFILE</option>
                </select>
            </div>
            <div class="form-group col-md-3">
                <label>存储位置</label>
                <input id="save_path" name="save_path" class="form-control" placeholder="存储位置"></input>
            </div>

            <div class="form-group col-md-1">
                <label>行分割符</label>
                <input type="text" id="line_terimial" name="line_terimial" class="form-control" value="\n"></input>
            </div>
            <div class="form-group col-md-1">
                <label>字段分隔符</label>
                <input id="FIELDS_terimial" name="FIELDS_terimial" class="form-control" value=","></input>
            </div>
        </div>

        <div class="form-row">
            <div class="form-group col-md-1">
                <label>map分隔符</label>
                <input id="map_terimial" name="map_terimial" class="form-control" value="|"></input>
            </div>
            <div class="form-group col-md-1">
                <label>元素分隔符</label>
                <input id="itemsplit" name="itemsplit" class="form-control" value=":"></input>
            </div>
            <div class="form-group col-md-3">
                <label>分区字段 字段类型,多级分区逗号分开</label>
                <input id="partition" name="partition" class="form-control" placeholder="col1 col1_type, col2 col2_type"></input>
            </div>
            <div class="form-group col-md-3">
                <label>分桶簇字段,多个字段逗号分开</label>
                <input id="cluster" name="cluster" class="form-control" placeholder="col1, col2"></input>
            </div>

            <div class="form-group col-md-3">
                <label>分桶排序字段 方式(ASC|DESC),多字段逗号分开</label>
                <input id="sorted" name="sorted" class="form-control" placeholder="col1 asc, col2 desc"></input>
            </div>
            <div class="form-group col-md-1">
                <label>分桶数量</label>
                <input id="t_num" name="t_num" class="form-control" placeholder="分桶数量"></input>
            </div>
        </div>
    {% endif %}
    {%if (db_driver_name == 'MYSQL') %}
            <div class="form-group col-md-3">
                <label>存储引擎</label>
                <select id="storageengine" name="storageengine" class="form-control">
                    <option selected id="InnoDB" name="InnoDB" value="InnoDB">InnoDB</option>
                    <option id="MyISAM" name="MyISAM" value="MyISAM">MyISAM</option>
                    <option id="MEMORY" name="MEMORY" value="MEMORY">MEMORY</option>
                    <option id="Mrg_Myisam" name="Mrg_Myisam" value="Mrg_Myisam">Mrg_Myisam</option>
                    <option id="Blackhole" name="Blackhole" value="Blackhole">Blackhole</option>
                </select>
            </div>

            <div class="form-group col-md-4">
                <label>字符集合</label>
                <select id="charset" name="charset" class="form-control">
                    <option selected id="utf8" name="utf8" value="utf8">utf8</option>
                    <option id="latin1" name="latin1" value="latin1">latin1</option>
                    <option id="big5" name="big5" value="big5">big5</option>
                    <option id="dec8" name="dec8" value="dec8">dec8</option>
                    <option id="cp850" name="cp850" value="cp850">cp850</option>
                    <option id="hp8" name="hp8" value="hp8">hp8</option>
                    <option id="koi8r" name="koi8r" value="koi8r">koi8r</option>
                    <option id="latin2" name="latin2" value="latin2">latin2</option>
                    <option id="swe7" name="swe7" value="swe7">swe7</option>
                    <option id="ascii" name="ascii" value="ascii">ascii</option>
                    <option id="ujis" name="ujis" value="ujis">ujis</option>
                    <option id="sjis" name="sjis" value="sjis">sjis</option>
                    <option id="hebrew" name="hebrew" value="hebrew">hebrew</option>
                    <option id="tis620" name="tis620" value="tis620">tis620</option>
                    <option id="euckr" name="euckr" value="euckr">euckr</option>
                    <option id="koi8u" name="koi8u" value="koi8u">koi8u</option>
                    <option id="gb2312" name="gb2312" value="gb2312">gb2312</option>
                    <option id="greek" name="greek" value="greek">greek</option>
                    <option id="cp1250" name="cp1250" value="cp1250">cp1250</option>
                    <option id="gbk" name="gbk" value="gbk">gbk</option>
                    <option id="latin5" name="latin5" value="latin5">latin5</option>
                    <option id="armscii8" name="armscii8" value="armscii8">armscii8</option>
                    <option id="ucs2" name="ucs2" value="ucs2">ucs2</option>
                    <option id="cp866" name="cp866" value="cp866">cp866</option>
                    <option id="keybcs2" name="keybcs2" value="keybcs2">keybcs2</option>
                    <option id="macce" name="macce" value="macce">macce</option>
                    <option id="macroman" name="macroman" value="macroman">macroman</option>
                    <option id="cp852" name="cp852" value="cp852">cp852</option>
                    <option id="latin7" name="latin7" value="latin7">latin7</option>
                    <option id="cp1251" name="cp1251" value="cp1251">cp1251</option>
                    <option id="cp1256" name="cp1256" value="cp1256">cp1256</option>
                    <option id="cp1257" name="cp1257" value="cp1257">cp1257</option>
                    <option id="binary" name="binary" value="binary">binary</option>
                    <option id="geostd8" name="geostd8" value="geostd8">geostd8</option>
                    <option id="cp932" name="cp932" value="cp932">cp932</option>
                    <option id="eucjpms" name="eucjpms" value="eucjpms">eucjpms</option>
                </select>
            </div>

        </div>
    {% endif %}
    <button type="submit" class="btn btn-primary btn-lg">提交</button>
</form>
<br><br>
    <table class="table table-bordered">
    <tr>
        <th>表ID</th>
        <th>表名</th>
        <th>表描述</th>
        <th>表所有者</th>
    </tr>
        {% for i in json_data %}
            <tr>
                <input type="hidden" name="db_id" value="{{ db_id }}"></input>
                <td>{{ i.get('id') }}</td>
                <td><a href="web_table_column_relate?db_id={{ db_id }}&table_id={{ i.get('id') }}">{{ i.get('table_name') }}</a></td>
                <td>{{ i.get('table_describe') }}</td>
                <td>{{ i.get('owner_name') }}</td>

                <td>
                    <input type="button" onclick="location.href='web_db_table_relate_modify?id={{ i.get('id') }}&db_id={{ db_id }}&table_id={{ i.get('table_id') }}&table_name={{ i.get('table_name') }}&table_describe={{ i.get('table_describe') }}&save_path={{ i.get('save_path') }}&is_valid=0'" value="删除">
                    </input>
                </td>

            </tr>
    {% endfor %}
    </table>

{% endblock %}
